<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="ru" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Система Управления</title>
		<!-- Bootstrap core CSS -->
		<link th:href="@{../asserts/css/bootstrap.min.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link th:href="@{../asserts/css/dashboard.css}" rel="stylesheet">
		<link th:href="@{../asserts/css/bootstrap-datetimepicker.min.css}" rel="stylesheet">
		<style type="text/css">
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			.chartjs-render-monitor {
				-webkit-animation: chartjs-render-animation 0.001s;
				animation: chartjs-render-animation 0.001s;
			}

			.hidden {
				display: none !important;
			}
		</style>
	</head>

	<body>
	<div th:replace="commons/bar::topbar"></div>
		<div class="container-fluid">
			<div class="row">
				<!--引入侧边栏-->
				<div th:replace="commons/bar::sidebar(activeUri='employees')"></div>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<h2>Список сотрудников</h2>
					<form class="form-inline" method="get" th:action="@{/employees}" id="query">
						<div class="form-group mx-sm-1 mb-2">
							<div class="col-sm-4">
								<label for="employeeShopId">Идентификатор магазина</label>
							</div>
							<select id="employeeShopId" class="form-control" name="employeeShopId">
								<option th:value="${null}">Выбирать...</option>
								<option th:each="shopInfo : ${shopInfos}" th:text="${shopInfo.shopId}"
										th:value="${shopInfo.shopId}"
										th:selected="${shopInfo.shopId eq employeeShopId}"></option>
							</select>
						</div>
						<div class="form-group mx-sm-1 mb-2">
							<input type="hidden" class="form-control" name="now" id="pageNo">
						</div>
						<div class="form-group mx-sm-1 mb-2">
							<input type="submit" class="btn btn-primary" value="Поиск">
						</div>
					</form>
					<a style="margin-bottom: 5px" type="button" class="btn btn-outline-primary float-right" th:href="@{/employee}">Добавлять</a>
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th class="text-center">Операционная</th>
									<th class="text-center">Имя</th>
									<th class="text-center">Код сотрудника</th>
									<th class="text-center">Пол</th>
									<th class="text-center">Телефон</th>
									<th class="text-center">Место расположения</th>
									<th class="text-center">День рождения</th>
									<th class="text-center">Дата вступления</th>
									<th class="text-center">Банковская карта</th>
									<th class="text-center">Штаб-квартира</th>
									<th class="text-center">Оплата труда</th>
									<th class="text-center">Магазин</th>
									<th class="text-center">Роли</th>
								</tr>
							</thead>
							<tbody>
								<tr th:each="employee:${pageInfo.list}">
									<td class="align-middle">
										<div class="btn-group" role="group" aria-label="Basic example">
											<a type="button" class="btn btn-sm btn-primary" th:href="@{/employee/}+${employee.id}">Модификация</a>
											<form th:action="@{/employee/}+${employee.id}" method="post">
												<input type="hidden" name="_method" value="delete">
												<button type="submit" class="btn btn-sm btn-danger">Удалять</button>
											</form>

										</div>
									</td>
									<td class="align-middle text-center" th:text="${employee.username}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeCode}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeGender}=='00'?'Женщина':'Мужчина'"></td>
									<td class="align-middle text-center" th:text="${employee.employeePhone}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeLocation}">

									</td>
									<td class="align-middle text-center" th:text="${#dates.format(employee.employeeBirthday, 'dd/MM/yyyy')}"></td>
									<td class="align-middle text-center" th:text="${#dates.format(employee.employeeEntryDate, 'dd/MM/yyyy')}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeBankcard}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeIsHeadquarter}=='01'?'Да':'Нет'"></td>
									<td class="align-middle text-center" th:text="${employee.employeeSalary}"></td>
									<td class="align-middle text-center" th:text="${employee.employeeShopId}"></td>
									<td class="align-middle text-center">
										<span th:each="i : ${employee.roles}">
	     									<span th:each="j : ${i.description}" th:text="${j}"></span>
										</span>
                                    </td>
								</tr>
							</tbody>
						</table>
                        <nav aria-label="Page navigation example">
                            <ul class="pagination justify-content-end">
                                <!-- 上一页  -->
                                <li class="page-item disabled" th:if="${pageInfo.pageNum} eq 1">
                                    <a class="page-link" href="#" tabindex="-1" aria-disabled="true" th:href="@{javaScript:void(0)}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li class="page-item" th:if="${pageInfo.pageNum} ne 1">
                                    <a class="page-link" aria-disabled="false" th:href="@{/employees(pageNum=${pageInfo.pageNum}-1,employeeShopId=${employeeShopId})}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li th:each="i : ${#numbers.sequence(1, pageInfo.pages)}">
                                    <a class="page-link active" th:href="@{/employees(pageNum=${i},employeeShopId=${employeeShopId})}" th:text="${i}" th:value="${i}"></a>
                                </li>

                                <!-- 下一页  -->
                                <!-- 当当前页码为最后一页或者最后一页为0时，隐藏下一页按钮 当当前页码不等于总页码时，跳转下一页  -->
                                <li class="page-item disabled" th:if="${(pageInfo.pageNum eq pageInfo.pages) or (pageInfo.pages eq 0)}">
                                    <a class="page-link" href="#" tabindex="-1" aria-disabled="true" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li class="page-item" th:if="${pageInfo.pageNum ne pageInfo.pages}">
                                    <a class="page-link" th:href="@{/employees(pageNum=${pageInfo.pageNum}+1,employeeShopId=${employeeShopId})}" aria-disabled="false" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
					</div>
				</main>
			</div>
		</div>

		<script type="text/javascript" src="../asserts/js/jquery-3.2.1.slim.min.js"></script>
		<script type="text/javascript" src="../asserts/js/popper.min.js"></script>
		<script type="text/javascript" src="../asserts/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="../asserts/js/bootstrap-datetimepicker.min.js"></script>
		<script type="text/javascript" src="../asserts/js/locales/bootstrap-datetimepicker.ru.js"></script>

		<!-- Icons -->
		<script type="text/javascript" src="../asserts/js/feather.min.js"></script>
		<script>
			feather.replace()
		</script>

		<!-- Graphs -->
		<script type="text/javascript" src="../asserts/js/Chart.min.js"></script>
		<script>
			var ctx = document.getElementById("myChart");
			var myChart = new Chart(ctx, {
				type: 'line',
				data: {
					labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
					datasets: [{
						data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
						lineTension: 0,
						backgroundColor: 'transparent',
						borderColor: '#007bff',
						borderWidth: 4,
						pointBackgroundColor: '#007bff'
					}]
				},
				options: {
					scales: {
						yAxes: [{
							ticks: {
								beginAtZero: false
							}
						}]
					},
					legend: {
						display: false,
					}
				}
			});
		</script>
		<script>
			$('#datetimepicker').datetimepicker({
				language:'ru',
				minView: 'month',
				autoclose: true,
				setStartDate: new Date(),
				todayBtn: true,
				todayHighlight: true,
				keyboardNavigation: true
			}).on('changeDate', function (ev) {
				$(this).datetimepicker('hide');
			});

			$('#datetimepicker2').datetimepicker({
				language:'ru',
				minView: 'month',
				autoclose: true,
				setStartDate: new Date(),
				todayBtn: true,
				todayHighlight: true,
				keyboardNavigation: true
			}).on('changeDate', function (ev) {
				$(this).datetimepicker('hide');
			});
		</script>
		<script type="text/javascript">
			// 创建客户
			function createEmployeeUser() {
				$('#password').val(new Date().getSeconds().toString()+new Date().getMilliseconds());
				$('#employeeCode').val('100'+new Date().getMilliseconds());
				$('#inputFourthLevel').text($('#inputFirstLevel option:selected').text() +
						'-'+$('#inputSecondLevel option:selected').text()+
						'-'+$('#inputThirdLevel option:selected').text()+
						'-'+$('#inputFourthLevel option:selected').text());
			}
		</script>

	</body>

</html>